home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
mainbvb4
/
mailnblk.frm
< prev
next >
Wrap
Text File
|
1997-10-01
|
8KB
|
269 lines
VERSION 4.00
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
Caption = "Non-Blocking Sample"
ClientHeight = 3675
ClientLeft = 3360
ClientTop = 3105
ClientWidth = 5640
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 4080
Left = 3300
LinkTopic = "Form1"
ScaleHeight = 3675
ScaleWidth = 5640
Top = 2760
Width = 5760
Begin VB.TextBox Text4
Appearance = 0 'Flat
Height = 1575
Left = 600
MultiLine = -1 'True
TabIndex = 7
Top = 1440
Width = 4215
End
Begin VB.CommandButton Command1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Send Message"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 3
Top = 3120
Width = 2175
End
Begin VB.TextBox Text3
Appearance = 0 'Flat
Height = 285
Left = 1560
TabIndex = 2
Top = 840
Width = 2175
End
Begin VB.TextBox Text2
Appearance = 0 'Flat
Height = 285
Left = 1560
TabIndex = 1
Top = 480
Width = 2175
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 285
Left = 1560
TabIndex = 0
Top = 120
Width = 2175
End
Begin MailLib.mMail Mail1
Left = 0
Top = 1440
_Version = 327680
_ExtentX = 847
_ExtentY = 847
_StockProps = 0
Blocking = 0 'False
Debug = 0
Host = ""
Timeout = 0
ConnectType = 0
PopPort = 110
SmtpPort = 25
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
Caption = "Message:"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 480
TabIndex = 8
Top = 1200
Width = 975
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
Caption = "Subject:"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 6
Top = 840
Width = 1215
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
Caption = "SMTP Server:"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 5
Top = 480
Width = 1335
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
Caption = "To:"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 4
Top = 120
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Dim iState As Integer
Private Sub Command1_Click()
On Error GoTo Some_Err
'validate entries
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
MsgBox "Please fill in all values.", vbExclamation, "Missing Value"
Exit Sub
End If
Mail1.Debug = 1
'create a new message
Mail1.Action = MailActionNewMessage
Mail1.Date = Format$(Now, "ddd, dd mmm yyyy hh:mm:ss")
'
'Your user friendly name
Mail1.From = "Your Name"
'
'The return e-mail address
Mail1.EMailAddress = "you@yourdomain.com"
'
'the lucky recipient
Mail1.To = Text1.Text
Mail1.Subject = Text3.Text
'create the headers for the message
'
Mail1.Body(0) = Text4.Text
'basic host configuration
Mail1.Blocking = False
Mail1.Host = Text2.Text
Mail1.ConnectType = 0 'MailConnectTypeSMTP
'send the message
Command1.Enabled = False
MousePointer = 11
iState = MailActionConnect
Mail1.Action = MailActionConnect
'the Done event of the Mail control handles the
'next actions
Exit Sub
Some_Err:
MsgBox CStr(Err)
On Error Resume Next
Mail1.Action = MailActionDisconnect
MousePointer = 0
Command1.Enabled = True
End Sub
Private Sub Mail1_AsyncError(ByVal ErrorCode As Integer, ByVal ErrorMsg As String)
MsgBox "AsyncError: " & CStr(ErrorCode) & " - " & ErrorMsg
On Error Resume Next
iState = MailActionDisconnect
Mail1.Action = iState
End Sub
Private Sub Mail1_Debug(ByVal Message As String)
Debug.Print Message
End Sub
Private Sub Mail1_Done()
Select Case iState
Case MailActionConnect
Me.Caption = "Connected. Writing message..."
Mail1.Flags = MailDstIsHost
iState = MailActionWriteMessage
Mail1.Action = iState
Case MailActionWriteMessage
Me.Caption = "Message sent. Disconnecting..."
iState = MailActionDisconnect
Mail1.Action = iState
Case MailActionDisconnect
Me.Caption = "Disconnected!"
MousePointer = 0
Command1.Enabled = True